package leetcode.code0392;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public boolean isSubsequence(String s, String t) {
		if (s.equals("")) {
			return true;
		}
		char cs[] = s.toCharArray();
		char ct[] = t.toCharArray();
		int ps = 0, pt = 0;
		while (ps < cs.length) {
			char cur = cs[ps];
			while (pt < ct.length && ct[pt] != cur) {
				pt++;
			}
			if (pt == ct.length) {
				break;
			}
			pt++;
			ps++;
		}
		return ps == cs.length && pt <= ct.length;
	}

	@Override
	public void debug4() {
		HelpDebug.compare(false, this.isSubsequence("aaaaaa", "bbaaaa"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
